package wortubung;

import wortubung.util.CommonUtils;

@SuppressWarnings("serial")
public class WortUbungException extends RuntimeException {

	private String fileName;
	private int lineNumber = -1;

	public WortUbungException() {
		super();
	}

	public WortUbungException(String arg0, Throwable arg1) {
		super(arg0, arg1);
	}

	public WortUbungException(String arg0) {
		super(arg0);
	}

	public WortUbungException(Throwable arg0) {
		super(arg0);
	}

	public void setFileInfo(String fileName, int lineNumber) {
		this.fileName = fileName;
		this.lineNumber = lineNumber;
	}

	@Override
	public String getMessage() {
		String msg = CommonUtils.neverNull(super.getMessage());
		if (fileName != null) {
			msg += " (File: " + fileName;
			if (lineNumber > 0)
				msg += ", line #" + lineNumber;
			msg += ")";
		}
		return msg;
	}
}
